home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / grafik / converter / limbo4.0 / src / 3d / analysis.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-16  |  5.0 KB  |  136 lines

  1. #include "includes.h"
  2.  
  3. /**************************************|****************************************
  4. Routine   : CountType
  5. Input  par: Transformation *T (pointer to trans)
  6.             int type          (type to be counted)
  7. Output par: int               (counts)
  8. Function  : counts main-block and its subblocs of type 'type'. Does the counting
  9.             recursivly. 
  10. ***************************************|***************************************/
  11.  
  12.  unsigned long CountType3D(Transformation *T, int type)
  13.   {
  14.    unsigned long count=0,i,j,k;
  15.    
  16.    if (T->Type==type) count++;
  17.    if (T->Sub!=NULL)
  18.     {
  19.      for(i=0;i<2;i++)
  20.      for(j=0;j<2;j++)
  21.      for(k=0;k<2;k++) if (T->Sub[i][j][k]!=NULL) count += CountType3D(T->Sub[i][j][k],type);
  22.     }
  23.    return count;
  24.   }
  25.  
  26. /**************************************|****************************************
  27. Routine   : CountMainSubs
  28. Input  par: Transformation *T (pointer to trans)
  29. Output par: unsigned int (counted mainsub configurations)
  30. Function  : counts main-sub-configurations recursively.
  31. ***************************************|***************************************/
  32.  
  33.  unsigned long CountMainSubs3D(Transformation *T,unsigned long *PureMain,int level)
  34.   {
  35.    unsigned long count=1,i,j,k;   
  36.  
  37.    if (T->Sub!=NULL)
  38.     {
  39.      for(i=0;i<2;i++)
  40.      for(j=0;j<2;j++)
  41.      for(k=0;k<2;k++) 
  42.      if (T->Sub[i][j][k]!=NULL) 
  43.      { 
  44.        level--;
  45.        count +=  CountMainSubs3D(T->Sub[i][j][k],PureMain,level);
  46.       }
  47.     }
  48.    else (PureMain[level])++;
  49.    return count;
  50.   }
  51.  
  52. /**************************************|****************************************
  53. Routine   : HeadInfo
  54. Input  par: Transformation ***T (pointer to trans array)
  55.             LimboHeader *Head   (pointer to header structure)
  56. Output par: none
  57. Function  : Produce info-statistic on Limbo-Header (fractal code header).
  58. ***************************************|***************************************/
  59.  
  60.  void HeadInfo3D(Transformation ****T, LimboHeader *Head)
  61.   {
  62.    Parameter *Par=GimmeAParameter();
  63.    int i,j,k,x,y,z;
  64.    unsigned long edg=0,sha=0,mainsubs=0;
  65.    unsigned long *PureMain;
  66.    
  67.    vprintf(stderr,"\nFractal code info...");
  68.    
  69.    Par->XBits=Head->XBits;
  70.    Par->YBits=Head->YBits;
  71.    Par->ZBits=Head->ZBits;
  72.    
  73.    Par->SBits=Head->SBits;
  74.    Par->ABits=Head->ABits;
  75.    Par->AMax =Head->AMax/100.0;
  76.    Par->AMin =Head->AMin/100.0;
  77.    Par->DBits=Head->DBits;
  78.    Par->GBits=Head->GBits;
  79.    Par->TBits=Head->TBits;
  80.    
  81.    x=Head->MSBx*256+Head->LSBx;
  82.    y=Head->MSBy*256+Head->LSBy;
  83.    z=Head->MSBz*256+Head->LSBz;
  84.    
  85.    PureMain=GimmeALongArray(Head->NSquare+1);
  86.    for (i=0;i<Head->NSquare;i++) PureMain[i]=0;
  87.  
  88.    for (i=0;i<x/(Head->B<<Head->NSquare);i++) /* count edges + shades */
  89.    for (j=0;j<y/(Head->B<<Head->NSquare);j++)
  90.    for (k=0;k<z/(Head->B<<Head->NSquare);k++)
  91.     {
  92.      edg += CountType3D(T[i][j][k],EDGEBLOCK);
  93.      sha += CountType3D(T[i][j][k],SHADEBLOCK);
  94.      mainsubs += CountMainSubs3D(T[i][j][k],PureMain,Head->NSquare);
  95.     }
  96.    
  97.     {
  98.      unsigned long he=(sizeof(LimboHeader)+LIMBOSTRINGSIZE)*8;
  99.      unsigned long edgbit=1+Par->XBits+Par->YBits+Par->ZBits+Par->ABits+Par->DBits+1+Par->TBits;
  100.      unsigned long shabit=1+Par->GBits;
  101.      unsigned long ed=edg*edgbit;
  102.      unsigned long sh=sha*shabit;
  103.      unsigned long to=ed+sh+Par->SBits*mainsubs;
  104.      unsigned long ratio=(x*y*z*8*100)/to;
  105.      unsigned long SNR=Head->MSBSNR*256+Head->LSBSNR;
  106.      unsigned long cpu=Head->MSBCPU*256+Head->LSBCPU;
  107.      
  108.      vprintf(stderr,"\n   Size:(%d,%d,%d)  Offset:(%d,%d)",x,y,z,
  109.              Head->MSBox*256+Head->LSBox,Head->MSBoy*256+Head->LSBoy);
  110.      for (i=Head->NSquare;i>=0;i--) 
  111.      vprintf(stderr,"\n   Block size:  Domain:%2d  Range:%2d  Delta:%2d  Pure main blocks:%d",
  112.              Head->B<<(1+i),Head->B<<i,Head->Delta,PureMain[i]);
  113. /*
  114.      vprintf(stderr,"\n   Type:%d  Colors:%d  KeepDelta:%d ",
  115.              Head->Type,Head->Col,Head->KeepDelta,Head->Type);
  116. */
  117.      vprintf(stderr,"\n   Bits:  X:%d  Y:%d  Z:%d  Sub:%d  Alpha:%d  DeltaG:%d  G0:%d  TN:%d",
  118.              Par->XBits,Par->YBits,Par->ZBits,Par->SBits,Par->ABits,Par->DBits,
  119.              Par->GBits,Par->TBits);
  120.      vprintf(stderr,"\n   Range:  Alpha max:%1.2f  Alpha min:%1.2f",Par->AMax,Par->AMin);
  121.      vprintf(stderr,"\n   Header:                                         %7d [bit]",he);
  122.      vprintf(stderr,"\n   Mainsub: %9u blocks of size %2u [bit] = %10u [bit]",
  123.              mainsubs,Par->SBits,mainsubs*Par->SBits);
  124.      vprintf(stderr,"\n   Shades:  %9u blocks of size %2u [bit] = %10u [bit]",sha,shabit,sh);
  125.      vprintf(stderr,"\n   Edges:   %9u blocks of size %2u [bit] = %10u [bit]",edg,edgbit,ed);
  126.      vprintf(stderr,"\n   Total:                                           %u [bit] = %u [byte]",
  127.              to+he,(to+he+7)/8);
  128.      vprintf(stderr,"\n   Ratio:   %3.2f:1 = %3.2f%% = %1.3f [bpp]",
  129.              (float)ratio/100.0,10000.0/(float)ratio,(float)to/(float)(x*y*z));
  130.      vprintf(stderr,"\n   PSNR:    %3.2f [dB]\n   CPU Time:%5u [sec]",(float)SNR/100.0,cpu);
  131.     }
  132.  
  133.    FreeMeAULongArray(PureMain);
  134.   }
  135.  
  136.